/* This file was generated with JastAdd2 (http://jastadd.org) version R20121112 (r872) */
package parser;

import java.util.HashMap;
import java.util.Map;
/**
 * @production Assign : {@link Stmt} ::= <span class="component">{@link Id}</span> <span class="component">{@link Exp}</span>;
 * @ast node
 * @declaredat /h/d1/l/int13mka/workspace/CalcComputation/specification/MiniP.ast:6
 */
public class Assign extends Stmt implements Cloneable {
  /**
   * @apilevel low-level
   */
  public void flushCache() {
    super.flushCache();
  }
  /**
   * @apilevel internal
   */
  public void flushCollectionCache() {
    super.flushCollectionCache();
  }
  /**
   * @apilevel internal
   */
  @SuppressWarnings({"unchecked", "cast"})
  public Assign clone() throws CloneNotSupportedException {
    Assign node = (Assign)super.clone();
    return node;
  }
  /**
   * @apilevel internal
   */
  @SuppressWarnings({"unchecked", "cast"})
  public Assign copy() {
      try {
        Assign node = (Assign)clone();
        if(children != null) node.children = (ASTNode[])children.clone();
        return node;
      } catch (CloneNotSupportedException e) {
      }
      System.err.println("Error: Could not clone node of type " + getClass().getName() + "!");
      return null;
  }
  /**
   * Create a deep copy of the AST subtree at this node.
   * The copy is dangling, i.e. has no parent.
   * @return dangling copy of the subtree at this node
   * @apilevel low-level
   */
  @SuppressWarnings({"unchecked", "cast"})
  public Assign fullCopy() {
    try {
      Assign tree = (Assign) clone();
      tree.setParent(null);// make dangling
      if (children != null) {
        tree.children = new ASTNode[children.length];
        for (int i = 0; i < children.length; ++i) {
          if (children[i] == null) {
            tree.children[i] = null;
          } else {
            tree.children[i] = ((ASTNode) children[i]).fullCopy();
            ((ASTNode) tree.children[i]).setParent(tree);
          }
        }
      }
      return tree;
    } catch (CloneNotSupportedException e) {
      throw new Error("Error: clone not supported for " +
        getClass().getName());
    }
  }
  /**
   * @ast method 
   * @aspect Interpreter
   * @declaredat /h/d1/l/int13mka/workspace/CalcComputation/specification/Interpreter.jadd:21
   */
  void execute(Map<String, Integer> vars) {
    int value = getExp().value(vars);
    vars.put(getId().getID(), value);
  }
  /**
   * @ast method 
   * 
   */
  public Assign(int i) {
    super(i);
  }
  /**
   * @ast method 
   * 
   */
  public Assign(MiniP p, int i) {
    this(i);
    parser = p;
  }
  /**
   * @ast method 
   * 
   */
  public Assign() {
    this(0);


  }
  /**
   * @ast method 
   * 
   */
  public Assign(Id p0, Exp p1) {
    setChild(p0, 0);
    setChild(p1, 1);
  }
  /**
   * @ast method 
   * 
   */
  public void dumpTree(String indent, java.io.PrintStream pStream) {
    pStream.println(indent + "Assign");
        String childIndent = indent + "  ";
    for(int i = 0; i < getNumChild(); i++)
      getChild(i).dumpTree(childIndent, pStream);
  }
  /**
   * @ast method 
   * 
   */
  public Object jjtAccept(MiniPVisitor visitor, Object data) {
    return visitor.visit(this, data);
  }
  /**
   * @ast method 
   * 
   */
  public void jjtAddChild(Node n, int i) {
    checkChild(n, i);
    super.jjtAddChild(n, i);
}
  /**
   * @ast method 
   * 
   */
  public void checkChild(Node n, int i) {
    if(i == 0 && !(n instanceof Id))  throw new Error("Child number 0 of Assign has the type " + n.getClass().getName() + " which is not an instance of Id");
    if(i == 1 && !(n instanceof Exp))  throw new Error("Child number 1 of Assign has the type " + n.getClass().getName() + " which is not an instance of Exp");
  }
  /**
   * @apilevel low-level
   * @ast method 
   * 
   */
  public int getNumChild() {
    return 2;
  }
  /**
   * Replaces the Id child.
   * @param node The new node to replace the Id child.
   * @apilevel high-level
   * @ast method 
   * 
   */
  public void setId(Id node) {
    setChild(node, 0);
  }
  /**
   * Retrieves the Id child.
   * @return The current node used as the Id child.
   * @apilevel high-level
   * @ast method 
   * 
   */
  public Id getId() {
    return (Id)getChild(0);
  }
  /**
   * Retrieves the Id child.
   * <p><em>This method does not invoke AST transformations.</em></p>
   * @return The current node used as the Id child.
   * @apilevel low-level
   * @ast method 
   * 
   */
  public Id getIdNoTransform() {
    return (Id)getChildNoTransform(0);
  }
  /**
   * Replaces the Exp child.
   * @param node The new node to replace the Exp child.
   * @apilevel high-level
   * @ast method 
   * 
   */
  public void setExp(Exp node) {
    setChild(node, 1);
  }
  /**
   * Retrieves the Exp child.
   * @return The current node used as the Exp child.
   * @apilevel high-level
   * @ast method 
   * 
   */
  public Exp getExp() {
    return (Exp)getChild(1);
  }
  /**
   * Retrieves the Exp child.
   * <p><em>This method does not invoke AST transformations.</em></p>
   * @return The current node used as the Exp child.
   * @apilevel low-level
   * @ast method 
   * 
   */
  public Exp getExpNoTransform() {
    return (Exp)getChildNoTransform(1);
  }
}
